#include<stdio.h>
#include <unistd.h>
#include <sys/types.h>

int main(){
  printf("我将要开始一个进程，pid: %d , ppid: %d\n",getpid(),getppid());
  int id=fork();
  printf("id=%d\n",id);
  if(id==0)
  {
    while(1){
      printf("这是子进程, pid: %d, ppid: %d\n",getpid(),getppid());
      sleep(1);
    }
  } 
  else if(id>0){
    int cnt=5;
    while(cnt-->0){
      printf("这是父进程, pid: %d, ppid: %d,cnt=%d\n",getpid(),getppid(),cnt);
      sleep(1);
    }
  } 
  
  return 0;
}
